package com.hex.ds.hdrs.common.catalogue;

import cn.hutool.core.date.DateUtil;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.File;
import java.util.Date;
import java.util.List;
import java.util.UUID;

@Data
@Accessors
public class Catalogue {

    public Catalogue() {

    }

    public Catalogue(File file) {
        this.filePath = file.getAbsolutePath();
        this.fileName = file.getName();
        this.updateTime = DateUtil.formatDateTime(new Date(file.lastModified()));
        this.fileType = file.isFile() ? "FILE" : "DIR";
        this.fileSize = file.isFile() ? String.valueOf(file.length()) : null;
    }

    private UUID id = UUID.randomUUID();

    private String filePath;

    private String fileName;

    private String fileType;

    private String fileSize;

    private String updateTime;

    private List<Catalogue> children;

    private int fileLine;
}
